<%@ Page Language="C#" AutoEventWireup="true" %>

<%
    //
    // jQuery File Tree ASPX Connector
    //
    // Version 1.0
    //
    // Copyright (c)2008 Andrew Sweeny
    // asweeny@fit.edu
    // 24 March 2008
    //
    string dir;
    if (Request.Form["dir"] == null || Request.Form["dir"].Length <= 0)
        dir = "/";
    else
        dir = Request.Form["dir"];
    if (Session["logined_id"] == null)
    {
        Response.Write("No session value");
        Response.End();
        return;
    }

    string strSiteValues = Session["logined_id"].ToString();

    //string fullPhysicalPath = Server.MapPath("/sites/" + strSiteValues + dir);
    //string fullPhysicalPath = Server.MapPath("/evipro-test/assets/");
    string fullPhysicalPath = Server.MapPath("/Mydocuments/" + strSiteValues + "/" + dir);

    System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(fullPhysicalPath);

    Response.Write("<ul class=\"jqueryFileTree\" >\n"); // style=\"display: inline;\">\n");

    if (dir == "/assets/")
    {
        Response.Write("\t<li class=\"directory expanded\"><a href=\"#\" rel=\"" + dir + "/\">...</a>\n");
        Response.Write("<ul class=\"jqueryFileTree\" >\n");
    }

    foreach (System.IO.DirectoryInfo di_child in di.GetDirectories())
        Response.Write("\t<li class=\"directory collapsed\"><a href=\"#\" rel=\"" + dir + di_child.Name + "/\">" + di_child.Name + "</a></li>\n");
    foreach (System.IO.FileInfo fi in di.GetFiles())
    {
        string ext = "";
        if (fi.Extension.Length > 1)
            ext = fi.Extension.Substring(1).ToLower();

        Response.Write("\t<li class=\"file ext_" + ext + "\"><a href=\"#\" rel=\"" + dir + fi.Name + "\">" + fi.Name + "</a></li>\n");
    }

    if (dir == "/assets/")
    {
        Response.Write("</ul>");
        Response.Write("</li>");
    }
    Response.Write("</ul>");
%>
